package com.lagou.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lagou.mapper.OrderMapper;
import com.lagou.pojo.Orders;
import com.lagou.pojo.OrdersVO;
import com.lagou.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderServiceImpl implements OrderService {

    @Autowired
    private OrderMapper orderMapper;

    //根据id查询订单
    @Override
    public Orders queryById(Integer id) {
        return orderMapper.selectById (id);
    }

    //分页查询订单
    @Override
    public PageInfo<Orders> queryByPage(OrdersVO ordersVO) {
        //分页查询
        PageHelper.startPage (ordersVO.getCurrentPage (),ordersVO.getPageSize ());
        List<Orders> orders = orderMapper.selectByPage (ordersVO);
        System.out.println (orders  + "orders");
        return new PageInfo<> (orders);
    }

    //查询商品信息
    @Override
    public List<Integer> getProductIdListByOrderId(Integer id) {
        return orderMapper.getProductIdListByOrderId (id);
    }
}
